package org.jeecg.modules.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.ResultInfo;
import org.jeecg.modules.system.mapper.ResultInfoMapper;
import org.jeecg.modules.system.service.IResultInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: result_info
 * @Author: jeecg-boot
 * @Date:   2025-04-25
 * @Version: V1.0
 */
@Service
@Slf4j
public class ResultInfoServiceImpl extends ServiceImpl<ResultInfoMapper, ResultInfo> implements IResultInfoService {

    @Autowired
    ResultInfoMapper resultInfoMapper;

    @Override
    @Transactional
    public Result<?> doResult() {
        log.info("开始对账.....");
        List<ResultInfo> resultInfos = resultInfoMapper.selectDebitInfo();
        if(resultInfos== null || resultInfos.size()<=0){
            return Result.OK("对账完成，无不齐账目！");
        }
        resultInfoMapper.deleteAll();
        log.info("开始保存....");
        this.saveBatch(resultInfos);
        return Result.OK("对账完成！");
    }
}
